//cardGameFunctions.cpp
/********************************************************************************
*																				*
*	Author:			Jared Szechy												*
*	Assignment:		Assignment 8												*
*	Class:			CPS-151														*
*	Instructor:		V. Starkley													*
*	Due Date:		November 7													*
*																				*
*	This file implements the card game functions.								*
*																				*
********************************************************************************/
#include <ctime>
#include "cardGameFunctions.h"

void Deal(Deck& theDeck, CountedQue<Card>& theHand, int numCards)
{
	for (int i = 0; i < numCards; i++)
	{
		Card temp;
		temp = theDeck.getTopCard();
		theHand.Enqueue(temp);
	}
}

void showHand(ostream& fout, CountedQue<Card> theHand)
{
	CountedQue<Card> tempQ;
	tempQ = theHand;

	Card tempCard;

	while(!tempQ.IsEmpty())
	{
		tempQ.Dequeue(tempCard);
		fout << tempCard << endl;
	}
}

void shuffle(CountedQue<Card>& theHand)
{
	Card *theCards;
	Card aCard;
	bool *filled;
	int count = 0;
	int length;
	length = theHand.LengthIs();
	theCards = new Card [length];
	filled = new bool [length];

	for (int i = 0; i < length; i++)
		filled[i] = false;

	int r;
	srand(static_cast<unsigned int>(time(0)));

	while(count < length)
	{
   		r = rand() % length;
		if(!filled[r])
		{
			theHand.Dequeue(aCard);
			theCards[r] = aCard;
			filled[r] = true;
			count++;
		}
	}
		
	for (int i = 0; i < length; i++)
	{
		theHand.Enqueue(theCards[i]);
	}
}
	

